import { PayloadAction } from '@reduxjs/toolkit';
import { IUserInfo } from 'src/interface';
import { removeToken } from 'src/utils/storage';
import { State } from './initState';

export const loginSuccess = (state: State, action: PayloadAction<IUserInfo>) => {
  state.user = action.payload;
};
export const setUserToken = (state: State, action: PayloadAction<string>) => {
  state.token = action.payload;
};

export const logout = (state: State) => {
  state.token = '';
  removeToken();
};
